using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.Domain.Entity;
using NHibernate;
using NHibernate.Expression;


namespace Ghasam.Business.DAO.Impl
{
    public class InternalAccountingDao : DaoBase<InternalAccounting>, IInternalAccountingDao
    {
        #region IInternalAccountingDao Members

        public int Count()
        {
            ICriteria crit = base.Session.CreateCriteria(typeof(InternalAccounting));
            crit.SetProjection(Projections.Count("Id"));
            return crit.UniqueResult<int>();
        }

        public IList<InternalAccounting> GetAll(string orderby, bool desc, int pageSize, int pageNumber)
        {
            ICriteria crit = base.Session.CreateCriteria(typeof(InternalAccounting));

            if (desc)
                crit.AddOrder(Order.Desc(orderby));
            else
                crit.AddOrder(Order.Asc(orderby));

            return crit.SetMaxResults(pageSize).SetFirstResult(pageSize * pageNumber).List<InternalAccounting>();
        }

        #endregion
    }
}
